; ModuleID = '/Users/aserlili/Documents/Codes/llvm-build/test/OllvmTest/calculate.cpp'
source_filename = "/Users/aserlili/Documents/Codes/llvm-build/test/OllvmTest/calculate.cpp"
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128-Fn32"
target triple = "arm64-apple-macosx15.0.0"

%struct._opaque_pthread_once_t = type { i64, [8 x i8] }

@once_flag = global %struct._opaque_pthread_once_t { i64 816954554, [8 x i8] zeroinitializer }, align 8
@.str = private unnamed_addr constant [22 x i8] c"This runs only once!\0A\00", align 1
@_ZL10once_flag2 = internal global %struct._opaque_pthread_once_t { i64 816954554, [8 x i8] zeroinitializer }, align 8
@.str.1 = private unnamed_addr constant [31 x i8] c"[calculate] a=%lf,b=%lf,op=%c\0A\00", align 1

; Function Attrs: mustprogress noinline optnone ssp uwtable(sync)
define void @_Z13init_functionv() #0 {
entry:
  %call = call i32 (ptr, ...) @printf(ptr noundef @.str)
  ret void
}

declare i32 @printf(ptr noundef, ...) #1

; Function Attrs: mustprogress noinline optnone ssp uwtable(sync)
define noundef ptr @_Z11thread_funcPv(ptr noundef %arg) #0 {
entry:
  %arg.addr = alloca ptr, align 8
  store ptr %arg, ptr %arg.addr, align 8
  %call = call i32 @pthread_once(ptr noundef @once_flag, ptr noundef @_Z13init_functionv)
  ret ptr null
}

declare i32 @pthread_once(ptr noundef, ptr noundef) #1

; Function Attrs: mustprogress noinline optnone ssp uwtable(sync)
define void @_Z14init_function2v() #0 {
entry:
  %call = call i32 (ptr, ...) @printf(ptr noundef @.str)
  ret void
}

; Function Attrs: mustprogress noinline optnone ssp uwtable(sync)
define noundef ptr @_Z12thread_func2Pv(ptr noundef %arg) #0 {
entry:
  %arg.addr = alloca ptr, align 8
  store ptr %arg, ptr %arg.addr, align 8
  %call = call i32 @pthread_once(ptr noundef @_ZL10once_flag2, ptr noundef @_Z14init_function2v)
  ret ptr null
}

; Function Attrs: mustprogress noinline optnone ssp uwtable(sync)
define noundef double @_Z9calculateddc(double noundef %a, double noundef %b, i8 noundef signext %op) #0 {
entry:
  %conv1.reg2mem = alloca i32, align 4
  %retval = alloca double, align 8
  %a.addr = alloca double, align 8
  %b.addr = alloca double, align 8
  %op.addr = alloca i8, align 1
  store double %a, ptr %a.addr, align 8
  store double %b, ptr %b.addr, align 8
  store i8 %op, ptr %op.addr, align 1
  %0 = load double, ptr %a.addr, align 8
  %1 = load double, ptr %b.addr, align 8
  %2 = load i8, ptr %op.addr, align 1
  %conv = sext i8 %2 to i32
  %call = call i32 (ptr, ...) @printf(ptr noundef @.str.1, double noundef %0, double noundef %1, i32 noundef %conv)
  %3 = load i8, ptr %op.addr, align 1
  %conv1 = sext i8 %3 to i32
  store i32 %conv1, ptr %conv1.reg2mem, align 4
  %switchVar = alloca i64, align 8
  store i64 7595455551748308926, ptr %switchVar, align 8
  br label %loopEntry

loopEntry:                                        ; preds = %loopEnd, %entry
  %switchVar17 = load i64, ptr %switchVar, align 8
  switch i64 %switchVar17, label %switchDefault [
    i64 7595455551748308926, label %first
    i64 7595455549782075455, label %if.then
    i64 7595455551760193247, label %if.else
    i64 7595455550753809138, label %if.then4
    i64 7595455550843989070, label %if.else5
    i64 7595455550734173305, label %if.then8
    i64 7595455548287432647, label %if.else9
    i64 7595455547997850171, label %if.then12
    i64 7595455549559117498, label %if.then14
    i64 7595455549870076198, label %if.else15
    i64 7595455551755262754, label %if.else16
    i64 7595455550516896447, label %return
  ]

switchDefault:                                    ; preds = %loopEntry
  br label %loopEnd

first:                                            ; preds = %loopEntry
  %conv1.reload = load i32, ptr %conv1.reg2mem, align 4
  %cmp = icmp eq i32 %conv1.reload, 43
  br i1 %cmp, label %if.then, label %if.else

if.then:                                          ; preds = %loopEntry, %first
  %4 = load double, ptr %a.addr, align 8
  %5 = load double, ptr %b.addr, align 8
  %add = fadd double %4, %5
  store double %add, ptr %retval, align 8
  br label %return

if.else:                                          ; preds = %loopEntry, %first
  %6 = load i8, ptr %op.addr, align 1
  %conv2 = sext i8 %6 to i32
  %cmp3 = icmp eq i32 %conv2, 45
  br i1 %cmp3, label %if.then4, label %if.else5

if.then4:                                         ; preds = %loopEntry, %if.else
  %7 = load double, ptr %a.addr, align 8
  %8 = load double, ptr %b.addr, align 8
  %sub = fsub double %7, %8
  store double %sub, ptr %retval, align 8
  br label %return

if.else5:                                         ; preds = %loopEntry, %if.else
  %9 = load i8, ptr %op.addr, align 1
  %conv6 = sext i8 %9 to i32
  %cmp7 = icmp eq i32 %conv6, 42
  br i1 %cmp7, label %if.then8, label %if.else9

if.then8:                                         ; preds = %loopEntry, %if.else5
  %10 = load double, ptr %a.addr, align 8
  %11 = load double, ptr %b.addr, align 8
  %mul = fmul double %10, %11
  store double %mul, ptr %retval, align 8
  br label %return

if.else9:                                         ; preds = %loopEntry, %if.else5
  %12 = load i8, ptr %op.addr, align 1
  %conv10 = sext i8 %12 to i32
  %cmp11 = icmp eq i32 %conv10, 47
  br i1 %cmp11, label %if.then12, label %if.else16

if.then12:                                        ; preds = %loopEntry, %if.else9
  %13 = load double, ptr %b.addr, align 8
  %cmp13 = fcmp une double %13, 0.000000e+00
  br i1 %cmp13, label %if.then14, label %if.else15

if.then14:                                        ; preds = %loopEntry, %if.then12
  %14 = load double, ptr %a.addr, align 8
  %15 = load double, ptr %b.addr, align 8
  %div = fdiv double %14, %15
  store double %div, ptr %retval, align 8
  br label %return

if.else15:                                        ; preds = %loopEntry, %if.then12
  store double -1.000000e+00, ptr %retval, align 8
  br label %return

if.else16:                                        ; preds = %loopEntry, %if.else9
  store double -1.000000e+00, ptr %retval, align 8
  br label %return

return:                                           ; preds = %loopEntry, %if.else16, %if.else15, %if.then14, %if.then8, %if.then4, %if.then
  %16 = load double, ptr %retval, align 8
  ret double %16

loopEnd:                                          ; preds = %switchDefault
  br label %loopEntry
}

attributes #0 = { mustprogress noinline optnone ssp uwtable(sync) "frame-pointer"="non-leaf" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="apple-m1" "target-features"="+aes,+altnzcv,+ccdp,+ccidx,+complxnum,+crc,+dit,+dotprod,+flagm,+fp-armv8,+fp16fml,+fptoint,+fullfp16,+jsconv,+lse,+neon,+pauth,+perfmon,+predres,+ras,+rcpc,+rdm,+sb,+sha2,+sha3,+specrestrict,+ssbs,+v8.1a,+v8.2a,+v8.3a,+v8.4a,+v8a,+zcm,+zcz" }
attributes #1 = { "frame-pointer"="non-leaf" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="apple-m1" "target-features"="+aes,+altnzcv,+ccdp,+ccidx,+complxnum,+crc,+dit,+dotprod,+flagm,+fp-armv8,+fp16fml,+fptoint,+fullfp16,+jsconv,+lse,+neon,+pauth,+perfmon,+predres,+ras,+rcpc,+rdm,+sb,+sha2,+sha3,+specrestrict,+ssbs,+v8.1a,+v8.2a,+v8.3a,+v8.4a,+v8a,+zcm,+zcz" }

!llvm.module.flags = !{!0, !1, !2, !3, !4}
!llvm.ident = !{!5}

!0 = !{i32 2, !"SDK Version", [2 x i32] [i32 15, i32 5]}
!1 = !{i32 1, !"wchar_size", i32 4}
!2 = !{i32 8, !"PIC Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 1}
!4 = !{i32 7, !"frame-pointer", i32 1}
!5 = !{!"clang version 19.1.3 (git@github.com:zylc369/Arkari.git ef2500cb061e3b3f97cea27f8f8127a5478075b3)"}
